From 9552068222f0c4a8fd59d53f36331882ad31dafd Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Wed, 2 Aug 2006 09:20:09 +0100 Subject: [PATCH] There is an allocation-failure path in sched_credit.c that BUGs. The attached patch handles this potential failure case more gracefully. Signed-off-by: Charles Coffing --- xen/common/sched_credit.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 98e1e3e6c1..19cd2426ef 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -296,12 +296,17 @@ __runq_tickle(unsigned int cpu, struct csched_vcpu *new) cpumask_raise_softirq(mask, SCHEDULE_SOFTIRQ); } -static void +static int csched_pcpu_init(int cpu) { struct csched_pcpu *spc; unsigned long flags; + /* Allocate per-PCPU info */ + spc = xmalloc(struct csched_pcpu); + if ( spc == NULL ) + return -1; + spin_lock_irqsave(&csched_priv.lock, flags); /* Initialize/update system-wide config */ @@ -311,9 +316,6 @@ csched_pcpu_init(int cpu) if ( csched_priv.master >= csched_priv.ncpus ) csched_priv.master = cpu; - /* Allocate per-PCPU info */ - spc = xmalloc(struct csched_pcpu); - BUG_ON( spc == NULL ); INIT_LIST_HEAD(&spc->runq); spc->runq_sort_last = csched_priv.runq_sort; schedule_data[cpu].sched_priv = spc; @@ -323,6 +325,8 @@ csched_pcpu_init(int cpu) cpu_set(cpu, csched_priv.idlers); spin_unlock_irqrestore(&csched_priv.lock, flags); + + return 0; } #ifndef NDEBUG @@ -490,7 +494,10 @@ csched_vcpu_init(struct vcpu *vc) /* Allocate per-PCPU info */ if ( unlikely(!CSCHED_PCPU(vc->processor)) ) - csched_pcpu_init(vc->processor); + { + if ( csched_pcpu_init(vc->processor) != 0 ) + return -1; + } CSCHED_VCPU_CHECK(vc); -- 2.30.2